package com.data.modules.online.cgform.enhance.impl;

import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgform.util.OnlineImportValidator;
import com.data.modules.online.config.exception.BusinessException;
import com.data.modules.online.cgform.enhance.CgformEnhanceJavaInter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component("cgformEnhanceImportDemo")
public class CgformEnhanceImportDemo implements CgformEnhanceJavaInter {

    private static final Logger f131a = LoggerFactory.getLogger(CgformEnhanceImportDemo.class);

    @Override
    public int execute(String tableName, JSONObject json) throws BusinessException {
        if (ConvertUtils.isEmpty(json.get("name"))) {
            json.put("name", "默认值");
            return 1;
        } else if (json.getString("name").equals(OnlineImportValidator.f336a)) {
            json.put("name", "默认值");
            throw new BusinessException("测试抛出异常error");
        } else if (json.getString("name").equals("hello")) {
            json.put("id", "testid123");
            json.put("name", "JAVA导入增强 测试修改");
            return 2;
        } else if (json.getString("name").equals("ok")) {
            return 0;
        } else {
            return 1;
        }
    }

    @Override
    public int execute(String tableName, Map<String, Object> map) throws BusinessException {
        return 1;
    }
}
